<template>
  <div>
    <div class="imgBack" style="position:relative;">
      <img :src="courseData.pic" class="imgView"/>
      <buy-lock-cover v-if="isLock(courseData)"/>
    </div>
    <p class="ellipsis1 nameLabel">{{courseData.title}}</p>
    <p class="ellipsis1 detailLabel">{{courseData.viewCount}}人加入学习</p>
    <p class="ellipsis1 priceLabel">¥ {{courseData.payPersonalNum}}</p>
  </div>
</template>

<script>
  import BuyLockCover from "./BuyLockCover";
  import EnterpriseLevelAPI from "../repo/api/EnterpriseLevelAPI";

  export default {
    props: ['courseData', 'subscriptionId'],
    components: {BuyLockCover},
    data() {
      return {
        buyInfo: {},
      }
    },
    mounted() {
    },
    methods: {
      isLock(courseData) {
        if (courseData.orgLevelId != 0 && courseData.orgLevelId  && this.subscriptionId) {
          //有等级限定的加锁规则
          let result = courseData.orgLevelConfig.indexOf(this.subscriptionId.toString())
          if (result === -1) {
            return true
          } else {
            return false
          }
        } else {
          //没有等级限定的不加锁
          return false
        }
      },
    }
  }
</script>

<style scoped>
  .imgBack {
    width: 100%;
    border-radius: 4px;
    height: 0;
    padding-bottom: 56.25%;
    overflow: hidden;
  }

  .imgView {
    width: 100%;
    object-fit: cover;
  }

  .nameLabel {
    margin-top: 8px;
    font-size: 14px;
    font-weight: bold;
    color: #303032;
  }

  .detailLabel {
    margin-top: 2px;
    font-size: 12px;
    color: #909092;
  }

  .priceLabel {
    margin-top: 4px;
    font-size: 12px;
    color: #1DA1F2;

  }
</style>
